<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<%@ page 
          import="java.util.Vector,
          org.displaytag.tags.TableTag,
          com.epro.standard.frontend.util.FileInfoUtil,
          com.epro.standard.frontend.util.ShowData,
          com.softplus.carrefour.hd.bltier.entity.RoutePath,
          com.softplus.carrefour.hd.bltier.admin.RoutePathManage,
          com.softplus.carrefour.hd.bltier.entity.UserLevel,
          com.softplus.carrefour.hd.bltier.entity.CfhdCaseHead,
          com.softplus.carrefour.hd.CFHDSystem"
%>
<html xmlns:epro>
<%@ taglib uri="/WEB-INF/HeadTag.tld" prefix="head"%>
<%@ taglib uri="/WEB-INF/displaytag-12.tld" prefix="display"%>
<%@ taglib uri="/WEB-INF/ListboxTag.tld" prefix="listbox"%>
<%@ taglib uri="/WEB-INF/NavigateBarTag.tld" prefix="navigate"%>
<%@ taglib uri="/WEB-INF/HintTag.tld" prefix="hint"%>
<%@ taglib uri="/WEB-INF/ErrorTag.tld" prefix="error"%>
<head:Head 
	author="Dee" 
	import ="listbox,navigateBar,hint,error" 
	styleFile="../theme/defaultTheme.css,../theme/CFRLTheme.css" 
	jsFile="../script/spTitleRefresh.js,../script/imgProp.js,../script/Alert.js,../script/showHints.js,../script/checkValidData.js,../script/convertDataType.js,../script/masterTable.js" 
	title="Routing Setup" >
     </head:Head>

<%

System.out.println("****************CFHDADMT03******************");
	ShowData showData 			 = new ShowData();
	//String userLogin             = request.getParameter("uid")==null?"":request.getParameter("uid") ;
	String uid             		= showData.CheckNull(request.getParameter("uid")) ;
	session.setAttribute("uid", uid) ;
	
	if(uid.equals("")) 
		uid	  = session.getAttribute("uid")!=null?session.getAttribute("uid").toString():"" ;
	System.out.println("****************uid******************"+uid);
	
	com.epro.standard.frontend.util.EproServletUtil servletUtil = new com.epro.standard.frontend.util.EproServletUtil(request) ;	
   	String caseType = request.getParameter("caseType")== null?"CaseType":servletUtil.getRequestValue("caseType");
	
	//***** define variable **************************
	FileInfoUtil	fileInfoUtil 			= session.getAttribute("fileInfoUtil")!=null?(FileInfoUtil)session.getAttribute("fileInfoUtil"):new FileInfoUtil() ;
  	fileInfoUtil.setMenuIDCode("CFHDADMT03 ") ;
  	fileInfoUtil.setMenuName("Routing Setup") ;
  	fileInfoUtil.setMenuDesc("To setup route path") ;
     fileInfoUtil.setMasterWording("Routing Setup");

	//***** define variable for MasterTag *********
	String linkParameter	= "?";
	String insertURL 		= "iframeInsert03.jsp";
          	insertURL		= "showModalDialog('" + insertURL + "', window, 'help=no;status=no;dialogWidth=600px;dialogHeight=400px;scrollbar=no');" ;
	 							
	String updateURL	= "CFHDADUP03.jsp";
	String detailURL 	= "CFHDADDT03.jsp";
		 
	String queryURL		= "";
	String qureyOnclick	= "window.location.href('" + queryURL +"')";
	
	String backURL						  = "/CFRL/CFRLWEBMN01.jsp?page=1" ; //request.getContextPath() + "/CFRLWEBMN01.jsp?page=1" ;
	String backClick						= "showProcessLayer();location='" + backURL + "'" ; //"parent.window.location.href('" + backURL +linkParameter+"')";
	
	String detailOnclickFirst   = "showModalDialog('CFHDADDT03.jsp?uid="+uid+"&index=" ;
	String detailOnclickLast    = "', window, 'help=no;status=no;dialogWidth=600px;dialogHeight=450px;scrollbar=no');" ;
	String updateOnclickFirst   = "showModalDialog('iframeUpdate03.jsp?pageName=" + updateURL+"&uid="+uid + "&index=" ;
  	String updateOnclickLast    = "', window, 'help=no;status=no;dialogWidth=600px;dialogHeight=450px;scrollbar=no');" ;
	
	String canSort		= "true";
	
	// variable for master table need	*********	
       String 	masterWidth             = "600";
       String	masterHeight            = "310";
       
       int listboxSelect = 1;
	   
    //Query User
 	RoutePathManage routePathManage = (RoutePathManage)CFHDSystem.getControlClass("ROUTE_PATH");
    Vector dataVector = new Vector();
    
  if(!(caseType.equals("caseType")))
  {
    dataVector = routePathManage.getRoutePathByCaseType(caseType); 
  }
      
  if(!(dataVector.isEmpty()))
  {  
    for(int i=0; i< dataVector.size(); i++)
    {
      RoutePath test = (RoutePath)dataVector.elementAt(i);
      String a = (String)test.getComp_id().getCaseType();
      String b = (String)test.getComp_id().getFromUserLevel();
    }
  }
  request.setAttribute( "routing",dataVector);
  session.setAttribute("RoutingVector",dataVector);
%>

<body>
<script type="text/javascript">
<!-- 
function selectCaseType()
{
	//alert(' action '+window.location.href.split('?')[0]);
	if(frm.caseType!=''){
			try{
		//			frm.action = window.location.href.split('?')[0]+"?uid=<%=uid%>";// window.location.href ;
					frm.action = '<%= request.getRequestURI() %>?uid=<%=uid%>';// window.location.href ;
			}catch(error){
				alert(error.getMessage())
			}
		
		frm.submit();
		showProcessLayer()
	}
	
}
function submitForm()
{
   if (checkBeforeDelete('deleteCheck'))
   {
   		if (showOConfirmDialog('Confirm','Confirm Delete','OK','Cancel') == 1)
        	frm.submit() ;
      <%//@include file="../include/eproSaveFormSubmit.jsp"%>
   }
    else
        showOErrorDialog('Error','No row selected for delete','OK');
}

function  clickInsert()
{
	
	showModalDialog("iframeInsert03.jsp?caseType="+'<%=caseType%>'+"&uid="+'<%=uid%>',window, 'help=no;status=no;dialogWidth=600px;dialogHeight=400px;scrollbar=no');
}

        function showProcessLayer(){
            try{
                document.all.programLayer.style.visibility='hidden';
                document.all.processingLayer.style.visibility='visible';
               }catch(error){}
        }
        
-->
</script> 
 <div id="processingLayer" style="visibility:hidden; position:absolute; left:100px; top:150px;">
<IMG alt="Waiting..." SRC="../images/background/Processing.gif" WIDTH="585" HEIGHT="136" BORDER="0">
</div>
<div style="width:98%;height:98%;margin:5px" id="programLayer">

<form name="frm" action="../servlet/com.softplus.carrefour.hd.frontend.servlet.administration.CFHDAD03" method="post" onsubmit="submitForm();return false;" style="margin-bottom:0px;">
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr><td>
	<input type="hidden" name="action1" value="delete">
	<input type="hidden" name="hCaseType" value="<%=caseType%>">
	<input type="hidden" name="uid" value="<%=uid%>">
     <%=fileInfoUtil.MasterHeadTable()%>
      <table align="center" border="0" width="100%">
       <tr>
       <td width="25%">&nbsp;</td>
        <td align="center" class="titleFont">
         Case Type :
         <%
	    			// list box of CaseType
	    			String listboxData[] = {"CaseType","P1","P2","P3","P4"};
					String listboxLabel[] = {"Select Case Type","User Question(P1)","Problem Report(P2)","Change Request(P3)","Service Request(P4)"};
	                  
	            	if(caseType.equals("CaseType")) listboxSelect = 1;
	            	if(caseType.equals("P1")) listboxSelect = 2;
	            	else if(caseType.equals("P2")) listboxSelect = 3;
	            	else if(caseType.equals("P3")) listboxSelect = 4;
	            	else if(caseType.equals("P4")) listboxSelect = 5;
	          			//	int listbox2Select = data.getM_ACTIVE().equals("Y") ? 1 : 2;
	      		%>
         </td>
         <td>
          <listbox:listbox name="caseType" data="<%=listboxData%>"
                           label="<%=listboxLabel%>"
                           selectedIndex="<%=listboxSelect%>" width="240"
                           onchange="selectCaseType()"/>
         </td>
         <td width="25%">&nbsp;</td>
       </tr>
      </table>
      <%= fileInfoUtil.MasterFootTable() %>
     
     </td></tr>
     <tr><td>
     <table width="100%" align="center" border="0" cellpadding="0" cellspacing="0">
       <tbody>
        <tr>
         <td class="borderFontColor">
          <!-- TOOL BAR -->
          <span style="width:100pt;">&nbsp;</span>
          <img alt="Back to Menu" src="../images/icon/toolbar/nBackToMenu.gif"
               onmouseover="this.src='../images/icon/toolbar/oBackToMenu.gif'"
               onmouseout="this.src='../images/icon/toolbar/nBackToMenu.gif'"
               style="cursor:hand" onclick="<%=backClick%>"></img>
          <%if(!caseType.equals("CaseType")&&!caseType.equals("")){%>
          <img alt="Add" src="../images/icon/toolbar/nAdd.gif"
               onmouseover="this.src='../images/icon/toolbar/oAdd.gif'"
               onmouseout="this.src='../images/icon/toolbar/nAdd.gif'"
               style="cursor:hand" onclick="clickInsert();"></img>
          <% } if(dataVector.size() > 0) {%>
          <img alt="Delete" src="../images/icon/toolbar/nDelete.gif"
               onmouseover="this.src='../images/icon/toolbar/oDelete.gif'"
               onmouseout="this.src='../images/icon/toolbar/nDelete.gif'"
               style="cursor:hand" onclick="submitForm();"></img>
          <% } %>
          <%= fileInfoUtil.MasterWording() %><br/><br/>
         </td>
        </tr>
        <tr>
         <td height="<%=masterHeight%>"  align="center">
          <!-- MASTER DATA -->
          <% if((dataVector.size() > 0)||(!caseType.equals("CaseType"))) {%>
          <div style="height:<%=masterHeight %>px; " class="tableContainer"
               id="tableContainer">
           <display:table name="routing" id="routing" styleClass="scrollTable" cellpadding="1"  
                          cellspacing="0" width="100%" border="0">
            <display:column style="width:5pt;"
                            title="<input type=\"checkbox\" name=\"deleteCheckAll\" alt=\"select \ unselect all\" onclick=\"checkAllBox('deleteCheck')\" >"
                            nowrap="true" headerStyleClass=" fixedHeader"
                            styleClass="scrollContent">
             <input type="checkbox"
                    value='<%=((RoutePath)routing).getComp_id().getCaseType()+ "|" +((RoutePath)routing).getComp_id().getFromUserLevel()+ "|" +((RoutePath)routing).getComp_id().getToUserLevel()%>'
                    name="deleteCheck"
                    onclick="checkEachBox('deleteCheck','deleteCheckAll')"></input>
            </display:column>
            <display:column style="width:85pt;" title="Case Type" nowrap="true"
                            sortable="true" headerStyleClass=" fixedHeader"
                            styleClass="scrollContent">
             <%=CfhdCaseHead.getStatusDesc(((RoutePath)routing).getComp_id().getCaseType())%>
            </display:column>
            <display:column title="From User Level" nowrap="true"
                            sortable="true" maxLength="41"
                            headerStyleClass=" fixedHeader"
                            styleClass="scrollContent">
             <%=UserLevel.getLevelName(((RoutePath)routing).getComp_id().getFromUserLevel())%>
            </display:column>
            <display:column title="To User Level" nowrap="true" sortable="true"
                            maxLength="41" headerStyleClass=" fixedHeader"
                            styleClass="scrollContent">
             <%=UserLevel.getLevelName(((RoutePath)routing).getComp_id().getToUserLevel())%>
            </display:column>
            <display:column title="Default Route" nowrap="true" sortable="true"
                            headerStyleClass=" fixedHeader" style="width:75pt;"
                            styleClass="scrollContent">
             <%=((RoutePath)routing).isDefaultAutoEscalate()?"Yes":"No" %>
            </display:column>
            <display:column title="&nbsp;" nowrap="true"
                            headerStyleClass=" fixedHeader"
                            styleClass="scrollContent" style="width:50px;">
             <img alt="Detail" style="cursor:hand"
                  src="../images/icon/toolbar/nDetail.gif"
                  onmouseover="Javascript: this.src='../images/icon/toolbar/oDetail.gif' "
                  onmouseout="Javascript: this.src='../images/icon/toolbar/nDetail.gif' "
                  onclick="Javascript: <%= detailOnclickFirst + pageContext.getAttribute("routing_rowNum") + detailOnclickLast %>"></img>
             <img alt="Edit" style="cursor:hand"
                  src="../images/icon/toolbar/nEdit.gif"
                  onmouseover="Javascript: this.src='../images/icon/toolbar/oEdit.gif' "
                  onmouseout="Javascript: this.src='../images/icon/toolbar/nEdit.gif' "
                  onclick="Javascript: <%= updateOnclickFirst + pageContext.getAttribute("routing_rowNum") + updateOnclickLast %>"></img>
            </display:column>
           </display:table>
          </div>
          <% } %>
         </td>
        </tr>
       </tbody>
      </table>
     </td></tr>
</table>
 </form>
 </div>
</body>
</html>
<%@ include file="../include/eproErrorAlert.jsp"%>
